package com.badminton.web.controller;

import com.badminton.web.model.TagWeightDO;
import com.badminton.web.model.request.*;
import com.badminton.web.model.response.BaseResponse;
import com.badminton.web.model.response.QueryUserEvaluateInfoResponseVO;
import com.badminton.web.model.response.QueryUserInfoResponseVO;
import com.badminton.web.service.IBadmintonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: peng.chen
 * @CreateTime: 2025-02-11
 * @Description:
 * @Version: 1.0.0
 */
@RestController
@Slf4j
@Api(tags = "功能接口")
public class BadmintonController {
    private final IBadmintonService badmintonService;

    public BadmintonController(IBadmintonService badmintonService) {
        this.badmintonService = badmintonService;
    }

    @PostMapping("/register")
    @ApiOperation("用户注册接口")
    public BaseResponse<Long> register(@RequestBody @Validated RegisterRequestVO registerRequestVO) {
        return BaseResponse.success(badmintonService.register(registerRequestVO));
    }

    @PostMapping("/login")
    @ApiOperation("用户登陆接口")
    public BaseResponse<Long> login(@RequestBody @Validated LoginRequestVO loginRequestVO) {
        return BaseResponse.success(badmintonService.login(loginRequestVO));
    }

    @PostMapping("/queryUserInfo")
    @ApiOperation("获取用户信息接口")
    public BaseResponse<QueryUserInfoResponseVO> queryUserInfo(@RequestBody QueryUserInfoRequestVO queryUserInfoRequestVO) {
        return BaseResponse.success(badmintonService.queryUserInfo(queryUserInfoRequestVO));
    }

    @PostMapping("/updateUserInfo")
    @ApiOperation("更新用户信息接口")
    public BaseResponse<Boolean> updateUserInfo(@RequestBody UpdateUserInfoRequestVO updateUserInfoRequestVO) {
        return BaseResponse.success(badmintonService.updateUserInfo(updateUserInfoRequestVO));
    }

    @PostMapping("/queryEvaluateInfo")
    @ApiOperation("获取用户评价信息接口")
    public BaseResponse<QueryUserEvaluateInfoResponseVO> queryUserEvaluateInfo(@RequestBody QueryUserEvaluateInfoRequestVO queryUserEvaluateInfoRequestVO) {
        return BaseResponse.success(badmintonService.queryUserEvaluateInfo(queryUserEvaluateInfoRequestVO));
    }

    @GetMapping("/match")
    @ApiOperation("用户匹配接口")
    public BaseResponse<Long> match(@RequestParam Long id) {
        return BaseResponse.success(badmintonService.match(id));
    }

    @PostMapping("/evaluate")
    @ApiOperation("用户评价接口")
    public BaseResponse<Boolean> evaluate(@RequestBody EvaluateRequestVO evaluateRequestVO) {
        return BaseResponse.success(badmintonService.evaluate(evaluateRequestVO));
    }

    @GetMapping("/queryTagWeightInfo")
    @ApiOperation("获取标签权重信息接口")
    public BaseResponse<List<TagWeightDO>> queryTagWeightInfo() {
        return BaseResponse.success(badmintonService.queryTagWeightInfo());
    }

    @PostMapping("/updateTagWeightInfo")
    @ApiOperation("更新标签权重信息接口")
    public BaseResponse<Boolean> updateTagWeightInfo(@RequestBody UpdateTagWeightInfoRequestVO updateTagWeightInfoRequestVO) {
        return BaseResponse.success(badmintonService.updateTagWeightInfo(updateTagWeightInfoRequestVO));
    }
}
